Skip to content

rustdoc: dep-info for standalone markdown inputs#154352

Open
notriddle wants to merge 3 commits intorust-lang:mainfrom
notriddle:emit-md
Open

rustdoc: dep-info for standalone markdown inputs#154352
notriddle wants to merge 3 commits intorust-lang:mainfrom
notriddle:emit-md

Conversation

@notriddle
Copy link
Copy Markdown
Contributor

@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Mar 25, 2026
Copy link
Copy Markdown
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's very nice! There are still parts of the diff I need to carefully review which I'll do later.

View changes since this review

if has_dep_info {
// Register the loaded external files in the source map so they show up in depinfo.
// We can't load them via the source map because it gets created after we process the options.
for external_path in &loaded_paths {
Copy link
Copy Markdown
Member

@fmease fmease Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flags like --theme and --extend-css don't seem to be used for standalone markdown files IINM, so they don't really need to be included in the dep-info. Of course, impl'ing that isn't worth the complexity, this approach is fine as is imo.

let mut md_opts = opt.clone();
md_opts.output = cx.dst.clone();
md_opts.external_html = cx.shared.layout.external_html.clone();
let file = try_err!(cx.sess().source_map().load_file(&index_page), &index_page);
Copy link
Copy Markdown
Member

@fmease fmease Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested your patch locally and ran rustdoc test.md --index-page my-index-page.md --emit=dep-info (with the appropriate source files) but my-index-page.md wasn't listed in the resulting dep info (for comparison, --html-after-content did obv work as the tests also confirm); I might've overlooked something tho.

Note that the custom index page isn't properly tracked in "normal mode" either (where the source file is Rust), neither on main nor on your branch AFAICT.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.

I notice that write_dep_info is run before the renderer is run. To fix this, I either need to add the file to the source map separately (which can be done the same way --html-before-content and related options are done), or move when the renderer runs.

The less risky option, at least in the short term, is adding the file separately.

@rust-log-analyzer

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants